home *** CD-ROM | disk | FTP | other *** search
/ Ahoy: Best of 1985 / Ahoy_Best_of_1985_1986_Double_L.d64 / dir manip. d'85 (.txt) < prev    next >
Commodore BASIC  |  2022-10-26  |  6KB  |  171 lines

  1. 10 rem ******************************
  2. 20 rem * directory manipulator init *
  3. 30 rem ******************************
  4. 40 print"[147]"tab(9)"[144]directory manipulator[159]"
  5. 50 printtab(5)"insert diskette to manipulate":gosub1430
  6. 60 dimf$(144):fori=1to11:fl$=fl$+chr$(0):next:ty$=chr$(131)+chr$(18)+chr$(0)
  7. 70 dims%(18):s%(1)=1:fori=1to17
  8. 80 ifi=6thens%(i+1)=2:next
  9. 90 ifi=12thens%(i+1)=3:next
  10. 100 s%(i+1)=s%(i)+3:next
  11. 110 t=18:s=1:n=1:ok=0
  12. 120 sp$="":fori=1to16:sp$=sp$+chr$(160):next
  13. 130 rem ******************
  14. 140 rem * init disk unit *
  15. 150 rem ******************
  16. 160 open15,8,15,"i0":gosub1550
  17. 170 printtab(12)" disk unit ok !"
  18. 180 rem **************************
  19. 190 rem * read directory routine *
  20. 200 rem **************************
  21. 210 open2,8,2,"#"
  22. 220 print#15,"u1";2;0;t;s
  23. 230 gosub1550
  24. 240 get#2,t$,s$:rem * track & sector of next dir entry *
  25. 250 t=asc(t$+chr$(0)):s=asc(s$+chr$(0))
  26. 260 fori=1to8
  27. 270 f$="":forx=1to30:rem * get directory entries *
  28. 280 get#2,b$:b=asc(b$+chr$(0)):ifx=1thena=b
  29. 290 ifx=4thenc=b
  30. 300 f$=f$+chr$(b):nextx
  31. 310 ifa<>0or(a=0andc=160)thenf$(n)=f$:n=n+1
  32. 320 get#2,b$,b$:nexti:rem * dir entries 2-7 garbage 1st 2 bytes *
  33. 330 ift<>0then220
  34. 340 rem ***************************
  35. 350 rem * print directory routine *
  36. 360 rem ***************************
  37. 370 z=1:od=0:p1=20:pg=p1:x=int((n-1)/2)+1:if(n-1)-(2*(x-1))=1thenx=x+1:od=1
  38. 380 xx=x-1:pc=int(xx/pg):if(xx/pg)-pc<>0thenpc=pc+1
  39. 390 ifxx>pgthenx=pg+1
  40. 400 fori=1toxx:print"[144]"right$(str$(z),2)"[159]";mid$(f$(z),4,16):z=z+1
  41. 410 ifod=0or(od=1and2*xx<>x)thenprinttab(19)"[145][144]"right$(str$(x),2)"[159]";mid$(f$(x),4,16):x=x+1
  42. 420 ifint(i/pg)=1andpc>=2thenpg=pg+p1:gosub1430:pc=pc-1:goto440
  43. 430 goto460
  44. 440 z=x:ifpc=>2thenx=z+p1
  45. 450 ifpc=1thenx=int(((2*xx)-(2*i))/2)+z
  46. 460 nexti
  47. 470 close15:close2
  48. 480 rem *****************
  49. 490 rem * check dir ok? *
  50. 500 rem *****************
  51. 510 print:print"directory ok (y/n)";:input"n[157][157][157]";ok$
  52. 520 ifok$<>"y"andok$<>"n"thenprint"[145][145][145]":goto510
  53. 530 ifok$="y"andok=0thengoto1660:rem * exit dir manipulator *
  54. 540 ifok$="y"andok=1thengoto730:rem * re-write directory *
  55. 550 rem ********************
  56. 560 rem * select manip cmd *
  57. 570 rem ********************
  58. 580 print"select directory manipulation command:"
  59. 590 getcm$:ifcm$=""then590
  60. 600 ifcm$="[133]"thenprint"re-list directory":goto370
  61. 610 ifcm$="h"thengosub1340:goto370
  62. 620 ok=1:ifcm$="[137]"thenprint"alphabatize directory":gosub920:goto370
  63. 630 ifcm$="[134]"thenprint"insert blank entry":gosub1010:goto370
  64. 640 ifcm$="[138]"thenprint"delete blank entries":gosub1050:goto370
  65. 650 ifcm$="[135]"thenprint"insert -----[146] entry":gosub1130:goto370
  66. 660 ifcm$="[139]"thenprint"insert 'remark' entry":gosub1170:goto370
  67. 670 ifcm$="[136]"thenprint"swap directory entries":gosub1230:goto370
  68. 680 ifcm$="[140]"thenprint"delete directory entry":gosub1280:goto370
  69. 690 print"[147]":goto580
  70. 700 rem **********************
  71. 710 rem * re-write directory *
  72. 720 rem **********************
  73. 730 print"[147]  writing new directory...please wait![146]"
  74. 740 f$="":fori=1to32:f$=f$+chr$(0):nexti
  75. 750 open15,8,15,"i0":gosub1550
  76. 760 printtab(12)" disk unit ok !"
  77. 770 open2,8,2,"#":x=int((n-1)/8):xx=0:if((n-1)/8)-x<>0thenx=x+1
  78. 780 fori=1tox:print#15,"b-p:";2;0:rem * position buffer pointer *
  79. 790 t=18:ifi=xthent=0:rem * set next dir sec pointer to 0 if last sector *
  80. 800 print#2,chr$(t);chr$(s%(i+1));:rem * pointer to next tr/se of dir *
  81. 810 forz=1to8:xx=xx+1
  82. 820 ifxx=>nthenprint#2,f$;:goto850
  83. 830 print#2,f$(xx);:rem * put dir entries into buffer *
  84. 840 ifz<>8andxx<>(n-1)thenprint#2,"sg";:rem * trash bytes for dir entries 2-7 *
  85. 850 nextz
  86. 860 print#15,"u2:";2;0;18;s%(i):rem * write dir sector *
  87. 870 print"writing track 18 sector"str$(s%(i))
  88. 880 nexti:close2:close15:goto1660
  89. 890 rem *************************
  90. 900 rem * alphabatize directory *
  91. 910 rem *************************
  92. 920 x=n
  93. 930 x=int(x/2):ifx=0thenreturn
  94. 940 fori=1to((n-1)-x):y=i
  95. 950 z=y+x:ifmid$(f$(y),4,16)<=mid$(f$(z),4,16)then970
  96. 960 ff$=f$(y):f$(y)=f$(z):f$(z)=ff$:y=y-x:ify>0then950
  97. 970 next:goto930
  98. 980 rem **********************
  99. 990 rem * insert blank entry *
  100. 1000 rem **********************
  101. 1010 gosub1490:f$(bl)=chr$(0)+chr$(0)+chr$(0)+sp$+fl$:return
  102. 1020 rem ************************
  103. 1030 rem * delete blank entries *
  104. 1040 rem ************************
  105. 1050 fori=1ton-1:ifasc(f$(i))=0then1070
  106. 1060 next:return
  107. 1070 forx=blton-1
  108. 1080 ifbl<n-1thenf$(x)=f$(x+1)
  109. 1090 next:n=n-1:goto1050
  110. 1100 rem **********************
  111. 1110 rem * insert ----- entry *
  112. 1120 rem **********************
  113. 1130 gosub1490:f$(bl)=ty$+"----------------"+fl$:return
  114. 1140 rem *************************
  115. 1150 rem * insert 'remark' entry *
  116. 1160 rem *************************
  117. 1170 gosub1490:print"enter remark:";:inputrm$:iflen(rm$)>16then1170
  118. 1180 iflen(rm$)<16thenfori=1to(16-len(rm$)):rm$=rm$+chr$(160):next
  119. 1190 f$(bl)=ty$+rm$+fl$:return
  120. 1200 rem *************************
  121. 1210 rem * swap directory entries *
  122. 1220 rem *************************
  123. 1230 print"1st ";:gosub1490:a=bl:print"2nd ";:gosub1490:f$(b)=f$(a):f$(a)=f$(bl)
  124. 1240 f$(bl)=f$(b):return
  125. 1250 rem **************************
  126. 1260 rem * delete directory entry *
  127. 1270 rem **************************
  128. 1280 gosub1490:forx=blton-1
  129. 1290 ifbl<n-1thenf$(x)=f$(x+1)
  130. 1300 next:n=n-1:return
  131. 1310 rem *************
  132. 1320 rem * help menu *
  133. 1330 rem *************
  134. 1340 print"[147]   directory manipulator help menu"
  135. 1350 print"   f1 -> re-list directory":print"   f2 -> alphabatize directory"
  136. 1360 print"   f3 -> insert blank entry":print"   f4 -> delete blank entries"
  137. 1370 print"   f5 -> insert -----[146] entry":print"   f6 -> insert 'remark' entry"
  138. 1380 print"   f7 -> swap directory entries":print"   f8 -> delete directory entry"
  139. 1390 gosub1430:return
  140. 1400 rem **********************
  141. 1410 rem * hit key subroutine *
  142. 1420 rem **********************
  143. 1430 print:printtab(13)"hit any key!!!"
  144. 1440 getck$:ifck$=""then1440
  145. 1450 return
  146. 1460 rem **************************************************
  147. 1470 rem * loc of entry/move dir array entries subroutine *
  148. 1480 rem **************************************************
  149. 1490 print"location of entry:    [157][157][157][157]";:inputbl:ifbl>n-1orbl<1thenprint"[145][145]":goto1490
  150. 1500 ifcm$="[136]"orcm$="[140]"thenreturn
  151. 1510 n=n+1:fori=n-1tobl+1step-1:f$(i)=f$(i-1):next:return
  152. 1520 rem *********************
  153. 1530 rem * disk status check *
  154. 1540 rem *********************
  155. 1550 input#15,en,em$,et,es:ifen<>0thengoto1600
  156. 1560 return
  157. 1570 rem ***************************
  158. 1580 rem * disk unit error routine *
  159. 1590 rem ***************************
  160. 1600 print"[147]"tab(12)"disk unit error!"
  161. 1610 print"error # -"en"[157]; track -"et"[157]; sector  -"se
  162. 1620 print"error msg - "em$:end
  163. 1630 rem ******************************
  164. 1640 rem * exit directory manipulator *
  165. 1650 rem ******************************
  166. 1660 print"[147]manipulate another diskette (y/n)";:input"n[157][157][157]";an$
  167. 1670 ifan$<>"y"andan$<>"n"then1660
  168. 1680 print"diskette being validated":open15,8,15:print#15,"v":print#15,"i":close15
  169. 1690 ifan$="y"thenrun
  170. 1700 end
  171.